package cn._51doit.live.udf;

import cn._51doit.live.pojo.GiftBean;
import com.alibaba.fastjson.JSON;
import org.apache.flink.streaming.api.functions.ProcessFunction;
import org.apache.flink.util.Collector;

public class JsonToGiftBeanFunction extends ProcessFunction<String, GiftBean> {


    @Override
    public void processElement(String line, Context ctx, Collector<GiftBean> out) throws Exception {

        try {
            GiftBean giftBean = JSON.parseObject(line, GiftBean.class);
            out.collect(giftBean);
        } catch (Exception e) {
            //e.printStackTrace();
        }
    }
}
